/**
 * 客户列表
*/

var wawa_adjust = new Object({
    table:null,
    init:function(){
        if(null != this.table)
            return;
        //console.info("init ok...")
        this.queryAdjust();
    },
    queryAdjust:function(){
        this.table = $('#tb_wawa_adjust').bootstrapTable({
            url: contextPath + '/wawa/inventory/adjustListData.json',
            responseHandler: function (res) {
                return res.data;
            },
            queryParams: function (params) {
                params.startDate = $('#startDate').val()
                params.stopDate = $('#stopDate').val()
                return params;
            },
            pagination: true,
            pageList: '[10,20, 50, 100]',
            //showColumns: true,
            showRefresh: true,
            showToggle: true,
            //showPaginationSwitch:true,
            sidePagination: 'server',
            //striped:true,
            sortable: false,
            height: 700,
            search: true,
            searchAlign: 'left',
            toolbar: '' +
            '<div style="float:left;display: inline-flex;">' +
            '       <label style="display:inline;">时间范围：</label>' +
            '       <div class="input-daterange input-group" id="adjust-datepicker-range">' +
            '           <input class="form-control" type="text" id="startDate" placeholder="开始时间" />' +
            '           <span class="input-group-addon" style="width:10px;">to</span>' +
            '           <input class="form-control" type="text" id="stopDate" placeholder="结束时间" />' +
            '       </div>' +
            '</div>' +
            '<div style="float: left;margin-right:5px;">' +
            '    <button class="btn btn-default" type="button" onclick="wawa_adjust.doSearch()">' +
            '        <i style="margin-right:2px;" class="fa fa-search"></i>' +
            '        <span>查询</span>' +
            '    </button>' +
            '</div>',
            idField: 'id',
            uniqueId: 'id',
            //singleSelect: true,
            clickToSelect: true,
            columns: [{
                field: 'id',
                title: 'ID',
                width: 100,
                visible:false
            }, {
                field: 'createTime',
                title: '调整时间',
                width: 100,
                formatter:function(value,row,index){
                    return (new Date(value)).Format("yyyy-MM-dd hh:mm");
                }
            }, {
                field: 'waWaName',
                title: '娃娃名称',
                width: 100
            }, {
                field: 'waWaType',
                title: '娃娃类型',
                width: 100
            }, {
                field: 'adjustBefore',
                title: '调整前库存',
                width: 100
            }, {
                field: 'adjustAfter',
                title: '调整后库存',
                width: 100
            }, {
                field: 'remark',
                title: '备注',
                width: 100
            }, {
                field: 'user.name',
                title: '操作人',
                width: 100
            }]
        });
        $('.search input').attr("placeholder", "娃娃名称|操作人|备注");
        wawa_adjust.loadDatePicker();
    },
    doSearch:function(){
        $('#tb_wawa_adjust').bootstrapTable('refresh');
    },
    loadDatePicker:function(){
        //日期控件加载
        var options = {
            orientation: $('body').hasClass('right-to-left') ? "auto right" : 'auto auto',
            todayBtn: "linked",
            format: 'yyyy-mm-dd',
            language: 'zh-CN',
            clearBtn: true,
            autoclose: true
        };
        $('#adjust-datepicker-range').datepicker(options);
    }

});